package router

import (
	beego "github.com/beego/beego/v2/server/web"
	"ksd-social-api/modules/common/pay/controller"
)

type PayRouter struct {
}

/**
 * @author feige
 * @date 2023-10-14
 * @version 1.0
 * @desc 需要登录路由
 */
func (router *PayRouter) InitRouter() beego.LinkNamespace {
	// 用户中心--子命名空间
	namespace := beego.NSNamespace("/pay",
		// 微信支付
		// 简历
		beego.NSCtrlPost("/resume/weixin/native/:opid", (*controller.WeixinNativeResumeController).NativePay),
		beego.NSCtrlPost("/resume/weixin/native/success", (*controller.WeixinNativeResumeController).QueryOrderByOutTradeNo),

		// 简历模板
		beego.NSCtrlPost("/resumetemplate/weixin/native/:opid", (*controller.WeixinNativeResumeTemplateController).NativePay),
		beego.NSCtrlPost("/resumetemplate/weixin/native/success", (*controller.WeixinNativeResumeTemplateController).QueryOrderByOutTradeNo),

		// 小册
		beego.NSCtrlPost("/note/weixin/native/:opid", (*controller.WeixinNativeNoteController).NativePay),
		beego.NSCtrlPost("/note/weixin/native/success", (*controller.WeixinNativeNoteController).QueryOrderByOutTradeNo),

		// 专题
		beego.NSCtrlPost("/special/weixin/native/:opid", (*controller.WeixinNativeSpecialController).NativePay),
		beego.NSCtrlPost("/special/weixin/native/success", (*controller.WeixinNativeSpecialController).QueryOrderByOutTradeNo),

		// 专题明细
		beego.NSCtrlPost("/specialbind/weixin/native/:specialId/:opid", (*controller.WeixinNativeSpecialBindController).NativePay),
		beego.NSCtrlPost("/specialbind/weixin/native/success", (*controller.WeixinNativeSpecialBindController).QueryOrderByOutTradeNo),

		// 栏目支付
		beego.NSCtrlPost("/channel/weixin/native/:opid", (*controller.WeixinNativeChannelController).NativePay),
		beego.NSCtrlPost("/channel/weixin/native/success", (*controller.WeixinNativeChannelController).QueryOrderByOutTradeNo),

		// 充值
		beego.NSCtrlPost("/coin/weixin/native/coin/:coin", (*controller.WeixinNativeCoinController).NativePayCoin),
		beego.NSCtrlPost("/coin/weixin/native/coin/success", (*controller.WeixinNativeCoinController).QueryOrderByCoinOutTradeNo),
		// 身份升级
		beego.NSCtrlPost("/vip/weixin/native/vip/:opid", (*controller.WeixinNativeVipController).NativePayVip),
		beego.NSCtrlPost("/vip/weixin/native/vip/success", (*controller.WeixinNativeVipController).QueryOrderByVipOutTradeNo),

		// 支付宝支付
		// 简历
		beego.NSCtrlPost("/resume/alipay/native/:opid", (*controller.AlipayNativeResumeController).NativePay),
		beego.NSCtrlPost("/resume/alipay/native/success", (*controller.AlipayNativeResumeController).QueryOrderByOutTradeNo),

		// 简历模板
		beego.NSCtrlPost("/resumetemplate/alipay/native/:opid", (*controller.AlipayNativeResumeTemplateController).NativePay),
		beego.NSCtrlPost("/resumetemplate/alipay/native/success", (*controller.AlipayNativeResumeTemplateController).QueryOrderByOutTradeNo),

		// 小册
		beego.NSCtrlPost("/note/alipay/native/:opid", (*controller.AlipayNativeNoteController).NativePay),
		beego.NSCtrlPost("/note/alipay/native/success", (*controller.AlipayNativeNoteController).QueryOrderByOutTradeNo),

		// 专题
		beego.NSCtrlPost("/special/alipay/native/:opid", (*controller.AlipayNativeSpecialController).NativePay),
		beego.NSCtrlPost("/special/alipay/native/success", (*controller.AlipayNativeSpecialController).QueryOrderByOutTradeNo),

		// 专题明细
		beego.NSCtrlPost("/specialbind/alipay/native/:specialId/:opid", (*controller.AlipayNativeSpecialBindController).NativePay),
		beego.NSCtrlPost("/specialbind/alipay/native/success", (*controller.AlipayNativeSpecialBindController).QueryOrderByOutTradeNo),

		// 栏目支付
		beego.NSCtrlPost("/channel/alipay/native/:opid", (*controller.AlipayNativeChannelController).NativePay),
		beego.NSCtrlPost("/channel/alipay/native/success", (*controller.AlipayNativeChannelController).QueryOrderByOutTradeNo),

		// 充值
		beego.NSCtrlPost("/coin/alipay/native/coin/:coin", (*controller.AlipayNativeCoinController).NativePayCoin),
		beego.NSCtrlPost("/coin/alipay/native/coin/success", (*controller.AlipayNativeCoinController).QueryOrderByCoinOutTradeNo),
		// 身份升级
		beego.NSCtrlPost("/vip/alipay/native/vip/:opid", (*controller.AlipayNativeVipController).NativePayVip),
		beego.NSCtrlPost("/vip/alipay/native/vip/success", (*controller.AlipayNativeVipController).QueryOrderByVipOutTradeNo),
	)
	return namespace
}

/**
 * @author feige
 * @date 2023-10-14
 * @version 1.0
 * @desc  不需要登录
 */
func (router *PayRouter) InitNoLoginRouter() beego.LinkNamespace {
	// 用户中心--子命名空间
	namespace := beego.NSNamespace("/pay",
		// 微信支付回调
		beego.NSCtrlPost("/weixin/native/success/callback", (*controller.WeixinNativeController).QueryOrderByOutTradeCallback),
		// 支付宝回调
		beego.NSCtrlGet("/alipay/native/success/return", (*controller.AlipayNativeController).QueryOrderByOutTradeReturn),
		beego.NSCtrlPost("/alipay/native/success/notify", (*controller.AlipayNativeController).QueryOrderByOutTradeNotify),

		beego.NSCtrlPost("/app/pay", (*controller.WeixinAppPayApi).MakeAppApiServicePrepay),
		beego.NSCtrlPost("/app/callback", (*controller.WeixinAppPayApi).QueryOrderByOutTradeCallbackApp),
		beego.NSCtrlPost("/h5/pay", (*controller.WeixinH5PayApi).MakeH5ApiServicePrepay),
		beego.NSCtrlPost("/h5/callback", (*controller.WeixinH5PayApi).QueryOrderByOutTradeCallbacKH5),
		beego.NSCtrlPost("/small/openid", (*controller.WeixinJSPayApi).GendWxAuthAPI),
		beego.NSCtrlPost("/small/pay", (*controller.WeixinJSPayApi).MakeJSApiServicePrepay),
		beego.NSCtrlPost("/small/callback", (*controller.WeixinJSPayApi).QueryOrderByOutTradeCallbackJS),
	)
	return namespace
}
